﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Y2.Filters
{
    public class TestActionFilter : Attribute, IActionFilter
    {
        private readonly ILogger<TestActionFilter> logger;

        public TestActionFilter(ILogger<TestActionFilter> logger)
        {
            this.logger = logger;
        }
        public void OnActionExecuted(ActionExecutedContext context)
        {
            logger.LogInformation(JsonConvert.SerializeObject(context.Result));
            logger.LogInformation("进去之后");
        }

        public void OnActionExecuting(ActionExecutingContext context)
        {
            logger.LogInformation(JsonConvert.SerializeObject(context.HttpContext.Request.Query));
            logger.LogInformation("进去之前");
        }
    }
}
